package com.yaohe.consumer.network.msghandler.impl;

import java.util.ArrayList;

import org.apache.mina.core.session.IoSession;

import com.yaohe.common.key.CouponId;
import com.yaohe.consumer.network.msghandler.MessageHandler;
import com.yaohe.consumer.service.YaoheService;
import com.yaohe.protocols.ProtocolError;
import com.yaohe.protocols.ProtocolProtos.Protocol;
import com.yaohe.protocols.ProtocolProtos.Protocol.IdList;

public class QrFetchHandler implements MessageHandler{

	private static QrFetchHandler qrFetchHandler = new QrFetchHandler();
	
	public static QrFetchHandler getHandler(){
		return qrFetchHandler;
	}
	
	public void handle(Protocol message, IoSession session) {
		// TODO Auto-generated method stub
		
		if(message.getErrorCode() == ProtocolError.ILLEGAL_ORDER_NUM_QUERY){
			YaoheService.dealWithQrAck(false, "", ProtocolError.ILLEGAL_ORDER_NUM_QUERY);
		}else if(message.getErrorCode() == ProtocolError.OUT_OF_ORDER_ACCOUNT){
			YaoheService.dealWithQrAck(false, "",ProtocolError.OUT_OF_ORDER_ACCOUNT);
		}else{
			String code = message.getMessage().getCouponUseConsumerResponse().getAuthCode();
			YaoheService.dealWithQrAck(true, code, 0);
		}
	}
}

